package com.hw.job_1;

/**
 * 编程统计字符串"ABCD123!@#$%ab"中大写字母、小写字母、数字、其它字符的个数并打印出来。
 */
public class job_1 {

    public static void main(String[] args) {

        String str = "ABCD123!@#$%ab";

        int upperCount = 0;
        int lowerCount = 0;
        int numberCount = 0;
        int otherCount = 0;

        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                upperCount++;
            } else if (c >= 'a' && c <= 'z') {
                lowerCount++;
            } else if (c >= '0' && c <= '9') {
                numberCount++;
            } else {
                otherCount++;
            }
        }

        System.out.println("大写字母个数 = " + upperCount);
        System.out.println("小写字母个数 = " + lowerCount);
        System.out.println("数字个数 = " + numberCount);
        System.out.println("其他字符个数 = " + otherCount);
    }
}
